//
// Created by zhaog on 30/03/17.
// 封装pic_store的thrift接口

#ifndef IMG_SVR_PIC_STORE_INTERFACE_H
#define IMG_SVR_PIC_STORE_INTERFACE_H

#include "common.hpp"
#include "vector"
#include "string"
#include "protocol/TBinaryProtocol.h"
#include "protocol/TProtocol.h"
#include "transport/TTransport.h"
#include <transport/TBufferTransports.h>
#include <transport/TSocket.h>
#include "pic_store_types.h"
#include "psSvr.h"
#include "map"
using std::map;

using namespace apache::thrift;
using namespace apache::thrift::protocol;
using namespace apache::thrift::transport;
using std::vector;
using std::string;
namespace pic_store_api {

    struct ImgStruct{
        string uid;
        string label;
        string img_name;
        string snapshot_time;
        string file_data;
    };

    class PicStoreInterface {
    public:
        static PicStoreInterface& SingletonInstance(){
            static PicStoreInterface psi;
            return psi;
        }
        void Init(string foshan_ip="14.17.109.77",string jinzhong_ip="61.240.41.129",string xianning_ip="58.52.135.162",string yancheng_ip="114.236.142.225");
        int GetImg(vector<ImgStruct>& imgs);
    private:
        int PatchGetParams(const vector<ImgStruct> &meta_info, set<pic_store::get_param> &foshan,
                           set<pic_store::get_param> &xianning, set<pic_store::get_param> &jinzhong,
                           set<pic_store::get_param> &yancheng);
        int WriteImgData(vector<ImgStruct>& imgs, map<string, string> &guid_data);
        PicStoreInterface(){}
        string _foshan_ip;
        string _jinzhong_ip;
        string _xianning_ip;
        string _yancheng_ip;
    };
}


#endif //IMG_SVR_PIC_STORE_INTERFACE_H
